import share from "../../share.js";
export function numUpdate() {
  this.numberArray.forEach((num) => {
    if (num.numNowHeight <= this.numHeight) {
      num.y =
        this.position.y -
        Math.abs(this.container.height) -
        num.numNowHeight -
        num.height;
      num.x = this.position.x - num.width / 2;
      num.numNowHeight += this.numSpeed;
    } else {
      share.stage.removeChild(num);
      this.numberArray.shift();
    }
  });
}

/**
 *
 * @param { PIXI.Sprite } num
 */
export function addNum(num) {
  this.numberArray.push(num);
  num.y = this.position.y - Math.abs(this.container.height) - num.height;
  num.x = this.position.x - num.width / 2;
  share.stage.addChild(num);
  num.numNowHeight = 0;
}

export function inscreaseBlood(num) {
  let numSprite = share.numbers.getSprite(num, "NoBlue");
  this.addNum(numSprite);
}

export function descreaseBlood(num) {
  let numSprite = share.numbers.getSprite(num, "NoViolet");
  this.addNum(numSprite);
}
export function recover() {
  this.increaseBlood(this.ability.recoverRate);
}

export function hurt(num) {
  this.descreaseBlood(num);
}
